<template>
  <div class="userInfo">
    <div class="avatarBox">
      <avatar :imgID="imgID" :fileType="fileType" :id="current_contact.id"></avatar>
    </div>
    <div class="userAttribute">
      <p :class="{'userName': true, 'singleLine': !currentInfo.remarks}">{{ currentInfo.remarks ? currentInfo.remarks : current_name }}</p>
      <p class="personalSignature" v-if="currentInfo.remarks">{{ current_name }}</p>
    </div>
  </div>
</template>

<script>
export default {
  computed: {
    // 当前选中用户/ 群组
    current_contact () {
      return this.$store.state.chatInformation.current_contact
    },
    // 当前选中用户 / 群组信息
    currentInfo () {
      if (this.current_contact.id_type === 1) {
        return this.$store.state.chatInformation.userList[this.current_contact.id]
      } else if (this.current_contact.id_type === 0) {
        return this.$store.state.chatInformation.systemNotiList.filter(item => item.id === this.current_contact.id)[0]
      } else {
        return this.$store.state.chatInformation.groupList[this.current_contact.id]
      }
    },
    // 当前用户姓名
    current_name () {
      if (this.current_contact.id_type === 1) {
        return this.currentInfo.user_name
      } else if (this.current_contact.id_type === 0) {
        return this.currentInfo.name
      } else {
        return this.currentInfo.group_name
      }
    },
    // 当前用户imgID
    imgID () {
      if (this.current_contact.id_type === 1) {
        return this.currentInfo.user_img_id
      } else if (this.current_contact.id_type === 0) {
        return this.currentInfo.id
      } else {
        return this.currentInfo.group_img_id
      }
    },
    // 当前用户fileType
    fileType () {
      if (this.current_contact.id_type === 2) {
        return 6
      } else if (this.current_contact.id_type === 0) {
        return ''
      } else {
        return 1
      }
    }
  }
}
</script>

<style scoped lang="scss">
.userInfo {
  height: 42px;
  font-size: 0;
  .avatarBox {
    width: 40px;
    height: 40px;
    display: inline-block;
    margin-right: 12px;
    vertical-align: top;
  }
  .userAttribute {
    display: inline-block;
    vertical-align: top;
    .userName {
      font-size: 14px;
      color: #0D172C;
      margin-bottom: 2px;
    }
    .singleLine {
      line-height: 40px;
    }
    .personalSignature {
      color: #5F7196;
      font-size: 12px;
    }
  }
}
</style>
